use bevy::prelude::*;
use rand::{Rng, SeedableRng};
use rand_chacha::ChaCha8Rng;

#[derive(Debug, Component)]
pub struct MovingCameraMarker;

#[derive(Component)]
pub enum ExampleViewports {
    PerspectiveMain,
    PerspectiveStretched,
    PerspectiveMoving,
    PerspectiveControl,
    OrthographicMain,
    OrthographicStretched,
    OrthographicMoving,
    OrthographicControl,
}

// 
pub const GRAVITY_CONSTANT: f32 = 0.001;
pub const NUM_BODIES: usize = 100;

#[derive(Component, Default)]
pub struct Mass(pub f32);
#[derive(Component, Default)]
pub struct Acceleration(pub Vec3);
#[derive(Component, Default)]
pub struct LastPos(pub Vec3);
#[derive(Component)]
pub struct Star;

#[derive(Bundle, Default)]
pub struct BodyBundle {
    pub mesh: Mesh3d,
    pub material: MeshMaterial3d<StandardMaterial>,
    pub mass: Mass,
    pub last_pos: LastPos,
    pub acceleration: Acceleration,
}

/// An entity that can take damage.
#[derive(Component, Deref, DerefMut)]
pub struct HitPoints(pub u16);

/// For damage to reach the wearer, it must exceed the armor.
#[derive(Component, Deref)]
pub struct Armor(pub u16);


// 
#[derive(Component)]
pub struct Person;

#[derive(Component)]
pub struct Name(pub String);


#[derive(Component)]
pub struct DisableOnClick;

#[derive(Component)]
pub struct EntityNameText;

#[derive(Component)]
pub struct Mine {
    pub pos: Vec2,
    pub size: f32,
}

impl Mine {
    pub fn random(rand: &mut ChaCha8Rng) -> Self {
        Mine {
            pos: Vec2::new(
                (rand.random::<f32>() - 0.5) * 1200.0,
                (rand.random::<f32>() - 0.5) * 600.0,
            ),
            size: 4.0 + rand.random::<f32>() * 16.0,
        }
    }
}